const mongoose = require('../../data/db')

const schema = mongoose.Schema({
    // 标题
    title: {
      type: String,
      default: '',
      require: true
    },
    // 作者
    authorId: {
      type: mongoose.Schema.Types.ObjectId, ref: 'User'
    },
    author: {
      type: String,
      default: '人间且慢行',
    },
    // // 状态
    status: {
      type: String || Number,
      default: '1'
    },
    // 内容
    content: {
      type: String,
      default: '',
      require: true
    },
    // 摘要
    abstract: {
      type: String,
      default: '',
      require: true
    },
    hot: {
      type: String || Number,
      default: 0,
    },
    // 标签 
    labelType: {
      type: String,
      default: 0,
      require: true
    },
    // 赞
    support: {
      type: Number,
      default: 0
    },
    // 阅读量
    watch: {
      type: Number,
      default: 0
    },
    // 原创 0：否，1：是
    original: {
      type: Number,
      default: 0
    },
    // 流程状态，0：草稿，1：审核中，2：通过，3：退回
    flow: {
      type: String,
      default: '1'
    },
    // 审核人
    auditor: {
      type: mongoose.Schema.Types.ObjectId, ref: 'User'
    },
    // 审核意见
    advice: {
      type: String,
      default: '1'
    },
    // 转发链接
    link: {
      type: String,
      default: ''
    }

}, {
    timestamps: {
      createdAt: 'createTime',
      updatedAt: 'updateTime'
    }
})

module.exports = mongoose.model('Article', schema)
